<?php
class Suport extends CI_Controller {


	public function __construct() {
		parent::__construct();
		if (! $this->usersession->userLoggedIn()) {
			$aResponse = array("error" => TRUE, "description" => "Sesiunea a expirat", "type" => "nosession");
			die(json_encode($aResponse));
		}
		$this->load->model('model_suport');
		$this->aUser = $this->usersession->currentUser();
		copyPost($this->aPost);
	}

	/**
	 * Functie care aduce datele in grid
	 */
	function getData() {
		echo json_encode($this->model_suport->getData($this->aPost));
	}

	/**
	 * Functie de editare / inserare element
	 * @return string json
	 */
	function operation() {
		$aResponse = array(
			"error"       => FALSE,
			"success"     => TRUE,
			"description" => "Datele au fost salvate"
		);
		$this->model_suport->operation($this->aPost);
		echo json_encode($aResponse);
	}

	/**
	 * Functie care aduce datele despre unei inregistrari
	 * @return string json
	 */
	function getRecord() {
		$aResult = $this->model_suport->getRecord($this->aPost);
		echo json_encode(array("error" => FALSE, "data" => $aResult));
	}

}
